package com.imCode.web;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by GO FOR IT on 2020/4/17.
 */
@WebServlet("/s1")
public class Servlet01 extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println(config.getServletContext().getInitParameter("k1"));
        System.out.println(config.getServletContext().getInitParameter("k2"));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println(request.getServletContext().getInitParameter("k1"));

        ServletContext servletContext = request.getServletContext();
        servletContext.setAttribute("s1", 100);
        System.out.println(servletContext.getAttribute("s1"));

    }
}
